package com.levi.test;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * new Data    System.
 */
public class DateTest {
    static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static void main(String[] args) {
//        System.out.println(System.currentTimeMillis());
//        DateTest.testDateFormat();
        DateTest.getBefore7Days(7,new Date());
    }

    /**
     * SimpleDateFormat 用法
     */
    private static void testDateFormat() {
        Date date = new Date();
        System.out.println("系统当前时间: "+date);

        String format = dateFormat.format(date);
        System.out.println("dateFormat格式后的时间: "+format);
    }

    /**
     * 获取指定时间date，过去n天的时间
     */
    private static void getBefore7Days(int past,Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.DATE,calendar.get(Calendar.DATE)-past);
        Date time = calendar.getTime();
        System.out.println("过去past天的日期是: "+dateFormat.format(time));
        Integer
    }
}
